﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using x.paypal.service.Settings;

namespace x.paypal.settings
{
    public class Configuration
    {
        private static string _BaseUri = ConfigurationManager.AppSettings[Header.BASEURI];
        private static string _RedirectUri = ConfigurationManager.AppSettings[Header.REDIRECT_URL];
        private static string _CancelUri = ConfigurationManager.AppSettings[Header.CANCEL_URL];
        private static string _IPNNotificationUri = ConfigurationManager.AppSettings[Header.IPN_URL];
        private static string _DefaultRequestDataFormat = ConfigurationManager.AppSettings[Header.REQUEST_DATAFORMAT];
        private static string _DefaultResponseDataFormat = ConfigurationManager.AppSettings[Header.RESPONSE_DATAFORMAT];
        
        public static Uri BaseUrl
        {
            get
            {
                if (_BaseUri!=null)
                {
                    return new Uri(_BaseUri); 
                }
                else
                {
                    throw new Exception(Errors.NULL_BASE_URI); 
                }
            }
        }

        public static Uri RedirectUri
        {
            get
            {
                if (_RedirectUri != null)
                {
                    return new Uri(_RedirectUri);
                }
                else
                {
                    throw new Exception(Errors.NULL_REDIRECT_URI);
                }
            }
        }

        public static Uri CancelUri
        {
            get
            {
                if (_CancelUri != null)
                {
                    return new Uri(_CancelUri);
                }
                else
                {
                    throw new Exception(Errors.NULL_CANCEL_URI);
                }
            }
        }
        public static Uri IPNNotification
        {
            get
            {
                if (_IPNNotificationUri != null)
                {
                    return new Uri(_IPNNotificationUri);
                }
                else
                {
                    throw new Exception(Errors.NULL_REDIRECT_URI);
                }
            }
        }
        public static string DefaultRequestDataFormat
        {
            get
            {
                return _DefaultRequestDataFormat;
            }
        }
        public static string DefaultResponseDataFormat
        {
            get
            {

                return _DefaultResponseDataFormat;
            }
        }
    }
}
